package com.wlyuan.open.domain;

import com.wlyuan.core.marker.NamedValue;
import com.wlyuan.core.marker.NamedValues;
import lombok.RequiredArgsConstructor;
import lombok.ToString;

import java.util.Map;

/**
 * @author
 * 推送业务类型
 */
@RequiredArgsConstructor
@ToString
public class PushType implements NamedValue<Integer> {
    private final Integer value;
    private final String name;

    public static final PushType ORDER = new PushType(1,"order");
    public static final PushType TRACK = new PushType(2,"track");

    private static final Map<Integer,PushType> MAP = new NamedValues(PushType.class);

    @Override
    public String getName() {
        return this.name;
    }

    @Override
    public Integer getValue() {
        return this.value;
    }

    public static PushType fromValue(Integer source){
        if(source == null){
            return null;
        }
        return MAP.get(source);
    }
}
